/******************************************************************************
 * Author:      671643387
 * Created:     2016/9/26
 *****************************************************************************/

var util = require('util');
var fs = require('fs');
var log4js = require('log4js');

/**
 * 初始化日志
 */
exports.init = function() {
    var appenders = [];

    appenders.push({
        category: 'debug',
        type: 'file',
        filename: 'log/fishgame.log',
        maxLogSize: 1024 * 1024 * 256,
        backups: 40,
        layout: {
            type: 'pattern',
            pattern: '[%d] %m',
        },
    });

    log4js.configure({'appenders': appenders});

    var debugLogger = log4js.getLogger('debug');
    debugLogger.setLevel('DEBUG');

    global.LOG = function(content) {
        console.log(content);
        debugLogger.info(content);
    };
    global.INFO = function(content) {
        console.log(content);
        debugLogger.info(content);
    };
    global.ERROR = function(content){
        console.error(content);
        debugLogger.info(content);
    };
    global.shutdownLog = function(callback) {
        log4js.shutdown(callback);
    };
    global.DEBUG = function(content) {
        console.log(content);
        debugLogger.info(content);
    };
};